home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Mousebroken 1.0.1 / source / Mousebroken source ƒ / cdev code / cdev gui.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  4.0 KB  |  127 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        cdev gui.c
  4.  
  5. Purpose:    This module handles all the DITL stuff in the cdev --
  6.             checking and unchecking controls, drawing the module icon.
  7.             
  8.  
  9. Mousebroken -=- your computer isn't truly broken until it's mousebroken
  10. Copyright (C) 1993 Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "cdev globals.h"
  30. #include "cdev gui.h"
  31. #include "GestaltEQU.h"
  32.  
  33. static pascal void DrawModuleIcon(DialogPtr theDlog, int theItem);
  34.  
  35. void CheckShowIcon(DialogPtr theDlog, int numItems, unsigned char showIconQQ)
  36. {
  37.     int                    itemType;
  38.     Handle                itemH;
  39.     Rect                box;
  40.     
  41.     GetDItem(theDlog, kButtonShowIcon+numItems, &itemType, &itemH, &box);
  42.     SetCtlValue((ControlHandle)itemH, showIconQQ ? 1 : 0);
  43. }
  44.  
  45. void CheckOnOff(DialogPtr theDlog, int numItems, Boolean checkOn)
  46. {
  47.     int                    itemType;
  48.     Handle                itemH;
  49.     Rect                box;
  50.     
  51.     GetDItem(theDlog, kButtonOn+numItems, &itemType, &itemH, &box);
  52.     SetCtlValue((ControlHandle)itemH, checkOn ? 1 : 0);
  53.     GetDItem(theDlog, kButtonOff+numItems, &itemType, &itemH, &box);
  54.     SetCtlValue((ControlHandle)itemH, checkOn ? 0 : 1);
  55. }
  56.  
  57. void IconSetup(DialogPtr theDlog, int numItems)
  58. {
  59.     int                    itemType;
  60.     Handle                itemH;
  61.     Rect                box;
  62.     
  63.     GetDItem(theDlog, kModuleIcon+numItems, &itemType, &itemH, &box);
  64.     SetDItem(theDlog, kModuleIcon+numItems, userItem+itemDisable, (ProcPtr)DrawModuleIcon, &box);
  65. }
  66.  
  67. void SetModuleSpecifics(DialogPtr theDlog, int numItems, PrefHandle cdevStorage)
  68. {
  69.     int                    itemType;
  70.     Handle                itemH;
  71.     Rect                box;
  72.     Str255                theCopyright, theInfo;
  73.     GrafPtr                oldPort;
  74.     
  75.     GetPort(&oldPort);
  76.     SetPort(theDlog);
  77.     GetDItem(theDlog, kButtonShowIcon+numItems, &itemType, &itemH, &box);
  78.     /* DrawModuleIcon needs access to the icon Handle, but has no access to cdevStorage, */
  79.     /* so we'll store the icon Handle in the refcon of a control for lack of anything cleaner */
  80.     SetCRefCon((ControlHandle)itemH, (unsigned long)(**cdevStorage).moduleIconHandle);
  81.     DrawModuleIcon(theDlog, kModuleIcon+numItems);
  82.     GetIndString(theCopyright, 668, 1);
  83.     GetIndString(theInfo, 668, 2);
  84.     GetDItem(theDlog, kModuleName+numItems, &itemType, &itemH, &box);
  85.     SetIText((ControlHandle)itemH, (**cdevStorage).moduleFS.name);
  86.     if (numItems>0)            /* system 6 needs to be told that it changed */
  87.         InvalRect(&box);
  88.     GetDItem(theDlog, kModuleCopyright+numItems, &itemType, &itemH, &box);
  89.     SetIText((ControlHandle)itemH, theCopyright);
  90.     if (numItems>0)
  91.         InvalRect(&box);
  92.     GetDItem(theDlog, kModuleInfo+numItems, &itemType, &itemH, &box);
  93.     SetIText((ControlHandle)itemH, theInfo);
  94.     if (numItems>0)
  95.         InvalRect(&box);
  96.     SetPort(oldPort);
  97.     
  98.     UseResFile((**cdevStorage).oldRefNum);    /* important in system 6 */
  99. }
  100.  
  101. static pascal void DrawModuleIcon(DialogPtr theDlog, int theItem)
  102. {
  103.     GrafPtr                oldPort;
  104.     OSErr                isHuman;
  105.     unsigned long        gestalt_temp;
  106.     int                    itemType;
  107.     Handle                itemH;
  108.     Rect                box;
  109.     Handle                tempHandle;
  110.  
  111.     GetPort(&oldPort);
  112.     SetPort(theDlog);
  113.     GetDItem(theDlog, kButtonShowIcon-kModuleIcon+theItem, &itemType, &itemH, &box);
  114.     tempHandle=(Handle)GetCRefCon((ControlHandle)itemH);    /* stored icon handle */
  115.     if (tempHandle!=0L)
  116.     {
  117.         GetDItem(theDlog, theItem, &itemType, &itemH, &box);
  118.         isHuman = Gestalt(gestaltQuickdrawVersion, &gestalt_temp);
  119.         if (isHuman || (gestalt_temp < gestalt8BitQD))
  120.             PlotIcon(&box, tempHandle);
  121.         else
  122.             PlotCIcon(&box, tempHandle);
  123.     }
  124.     
  125.     SetPort(oldPort);
  126. }
  127.